package router

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func FormParam(r *gin.Engine){
	r.POST("/getPostForm",func(ctx *gin.Context) {
		name:=ctx.PostForm("name")
		fmt.Printf("收到的name值为%s\n",name)
		age:=ctx.PostForm("age")
		fmt.Printf("收到的age值为%s\n",age)
	})

	//GetPostFormArray的测试
	r.POST("/getPostFormArray",func(ctx *gin.Context) {
		name,isOk:=ctx.GetPostFormArray("name")
		fmt.Printf("收到的name值为%#v,该键存在为%v\n",name,isOk)

		arr,isOk := ctx.GetPostFormArray("arr")
		fmt.Printf("收到的arr值为%#v,该键存在为%v\n",arr,isOk)
	})

	//GetPostFormMap的测试
	r.POST("/getPostFormMap",func(ctx *gin.Context) {
		person,isOk:=ctx.GetPostFormMap("person")
		fmt.Printf("收到的person值为%#v,该键存在为%v\n",person,isOk)
	})
}